package com.xm.controller;

import com.github.pagehelper.PageInfo;
import com.xm.pojo.PageVo;
import com.xm.pojo.UserData;
import com.xm.service.UserDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class UserDataController {

    @Autowired
    UserDataService service;

    @PostMapping("/insertUserData")
    public boolean insertUserData(@RequestBody UserData userData){
        return service.insertUserDataService(userData)>0;
    }

    @RequestMapping("/deleteUserData")
    public boolean deleteUserData(String realname){
        System.out.println(realname);
        return service.deleteUserDataService(realname)>0;
    }

    @PostMapping("/updateUserData")
    public boolean updateUserData(UserData userData){
        return service.updateUserDataService(userData)>0;
    }

    @RequestMapping("/queryUserDataList")
    public PageInfo<UserData> queryList(@RequestBody PageVo<String> pageVo){
        return service.queryListService(pageVo);
    }

    @PostMapping("/queryUserDataAll")
    public List<UserData> queryAll(){
        return service.queryAllService();
    }
}
